package com.hwua.util;

import java.util.HashMap;
import java.util.Map;

import com.hwua.entity.Book;

public class BookUtil {
	//键：对应书的编号，值对应的就是Book对象
	private static Map<String, Book> books = new HashMap<>();
	static{
		books.put("1", new Book("1", "水浒传", 50, "陈豪"));
		books.put("2", new Book("2", "红楼梦", 70, "张三"));
		books.put("3", new Book("3", "西游记", 80, "李四"));
		books.put("4", new Book("4", "三国演义", 60, "王五"));
		books.put("5", new Book("5", "金瓶梅", 100, "欧阳"));
	}
	
	/**
	 * 查找所有的书
	 * @return
	 */
	public static Map<String, Book> findAllBooks(){
		return books;
	}
	
	/**
	 * 根据编号查询一本书
	 * @param id
	 * @return
	 */
	public static Book findBookById(String id){
		return books.get(id);
	}

}
